import java.util.Scanner;
public class test528 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入年份：");
        int year = scanner.nextInt();
        System.out.print("请输入该年1月1日对应的星期数（0=周日, 1=周一, ..., 6=周六）：");
        int firstDayOfYear = scanner.nextInt();
        String[] months = {"January", "February", "March", "April", "May", "June",
                           "July", "August", "September", "October", "November", "December"};
        int[] daysInMonth = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
        if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) {
            daysInMonth[1] = 29;
        }
        int currentDay = firstDayOfYear;
        for (int i = 0; i < 12; i++) {
            String weekDay = switch (currentDay % 7) {
                case 0 -> "Sunday";
                case 1 -> "Monday";
                case 2 -> "Tuesday";
                case 3 -> "Wednesday";
                case 4 -> "Thursday";
                case 5 -> "Friday";
                case 6 -> "Saturday";
                default -> "";
            };
            System.out.printf("%s 1, %d is %s%n", months[i], year, weekDay);
            currentDay += daysInMonth[i];
        } scanner.close();
    }
}

